package com.tao.static_;

public class Example {
    public static void main(String[] args) {

        Person jack = new Person("jack");
        jack.sum();
        jack.count++;

        Person mary = new Person("mary");
        mary.sum();
        mary.count++;

        Person smith = new Person("smith");
        smith.sum();
        smith.count++;

        System.out.println("已签到" + smith.count + "人");
        //此时的count是静态成员变量，是所有对象共享的
        System.out.println("已签到" + jack.count + "人");
        System.out.println("已签到" + mary.count + "人");
        //所以不管哪个对象调用count结果都是3
        //而且任何一个对象去修改count修改的都是同一个值
    }
}

class Person{
    private String name;
    public static int count = 0;

    public Person(String name) {
        this.name = name;
    }
    public void sum(){
        System.out.println(name + "已签到");
    }
}